<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增项目立项')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-project-add">
        	<input name="ownerId" class="form-control" type="hidden" th:value="${ownerId}">
            <input name="deptId" class="form-control" type="hidden" th:value="${deptId}">
            <input type="hidden" id="approvename" name="approvename" th:value="${approvename}" />
            <div class="form-group">    
               <label class="col-sm-2 control-label ">项目编号：</label>
               <div class="col-sm-4">
                   <input name="orderNo" class="form-control" type="text"  >
               </div>
               <label class="col-sm-2 control-label is-required">立项日期：</label>
               <div class="col-sm-4">
                    <div class="input-group date">
                        <input name="lxAt" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
           </div>
           <div class="form-group">  
                <label class="col-sm-2 control-label is-required">合作联系人：</label>
                <div class="col-sm-4">
                	<div class="input-group">
                    	<input id="customerName" name="customerName" class="form-control" type="hidden">
                    	<input id="customerId" name="customerId" class="form-control" type="hidden">
                    	<input class="form-control" type="text" onclick="selectCustomer()" id="customerStr" readonly="true" required>
						<span class="input-group-addon"><i class="fa fa-search"></i></span>
					</div>
                </div>
                <label class="col-sm-2 control-label is-required">项目名称：</label>
                <div class="col-sm-4">
                    <input name="name" class="form-control" autoComplete="off" type="text" required >
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label ">项目描述：</label>
                <div class="col-sm-10">
                    <textarea name="descs" class="form-control" ></textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label ">项目类型：</label>
                <div class="col-sm-4">
                    <select name="proType" class="form-control" th:with="type=${@dict.getType('sj_proType')}" >
		                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
		            </select>
                </div>
                <label class="col-sm-2 control-label">项目总金额：</label>
                <div class="col-sm-4">
                    <input name="zongje" class="form-control" autoComplete="off" type="text">
                </div> 
            </div>
            <div class="form-group"> 
            	<label class="col-sm-2 control-label ">项目管理费%：</label>
                <div class="col-sm-4">
                    <input name="glf" class="form-control" autoComplete="off" type="text" >
                </div> 
            	<label class="col-sm-2 control-label ">内审出图费用：</label>
                <div class="col-sm-4">
                    <select name="nsctType" class="form-control" th:with="type=${@dict.getType('sj_nsctfy')}" >
		                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
		            </select>
                </div>
            </div>
            <div class="form-group"> 
            	<label class="col-sm-2 control-label ">建设单位联系人：</label>
                <div class="col-sm-4">
                    <input name="customerPerson" class="form-control" autoComplete="off" type="text" >
                </div> 
                <label class="col-sm-2 control-label ">建设单位联系电话：</label>
                <div class="col-sm-4">
                    <input name="customerPhone" class="form-control" autoComplete="off" type="text" >
                </div>
            </div>
            <div class="form-group"> 
            	<label class="col-sm-2 control-label ">是否外包：</label>
                <div class="col-sm-4">
                    <select id="isWb" name="isWb" class="form-control" >
						<option value="0">否</option>
						<option value="1">是</option>
					</select>
                </div>
                <label class="col-sm-2 control-label ">外包内容：</label>
                <div class="col-sm-4">
                    <input name="wbDescs" class="form-control" autoComplete="off" type="text" >
                </div>
            </div>
            <!-- 1 -->
            <div class="form-group"> 
            	<label class="col-sm-2 control-label ">项目面积：</label>
                <div class="col-sm-4">
                    <input name="mianji" class="form-control" autoComplete="off" type="text" >
                </div> 
                <label class="col-sm-2 control-label is-required">项目所属：</label>
                <div class="col-sm-4">
                    <select name="authority" class="form-control" required>
						<option th:each="cl:${deptlis}" th:value="${cl.deptId}" th:text="${cl.deptName}"></option>
					</select>
                </div> 
            </div>
            <div class="form-group">
            	<label class="col-sm-2 control-label is-required">商务、运营：</label>
                <div class="col-sm-4">
                	<div class="input-group">
                    	<input id="swyy" name="swyy" class="form-control" type="hidden">
                    	<input id="swyyId" name="swyyId" class="form-control" type="hidden">
                    	<input class="form-control" type="text" onclick="selectlevel1()" id="swyyStr" readonly="true" required>
						<span class="input-group-addon"><i class="fa fa-search"></i></span>
					</div>
                </div>
                <label class="col-sm-2 control-label is-required">部门审批：</label>
                <div class="col-sm-4">
                	<div class="input-group">
                    	<input id="bmspr" name="bmspr" class="form-control" type="hidden">
                    	<input id="bmsprId" name="bmsprId" class="form-control" type="hidden">
                    	<input class="form-control" type="text" onclick="selectlevel2()" id="bmsprStr" readonly="true" required>
						<span class="input-group-addon"><i class="fa fa-search"></i></span>
					</div>
                </div>
            </div>
            <div class="form-group"> 
            	<label class="col-sm-2 control-label ">项目年份：</label>
                <div class="col-sm-4">
                	<select name="yearStr" class="form-control" th:with="type=${@dict.getType('sj_yearStr')}" >
		                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
		            </select>
                </div>
                <label class="col-sm-2 control-label is-required">主体公司：</label>
            	<div class="col-sm-4">
            		<select name="ztdw" class="form-control" th:with="type=${@dict.getType('sj_gongs')}">
                    	<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                	</select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label ">备注：</label>
                <div class="col-sm-10">
                    <textarea name="memo" class="form-control" ></textarea>
                </div>
            </div>
            <div class="form-group">    
               <label class="col-sm-2 control-label is-required">申请人：</label>
               <div class="col-sm-4">
                   <input name="owner" class="form-control" th:value="${owner}" type="text"  readonly="readonly">
               </div>
               <label class="col-sm-2 control-label is-required">申请部门：</label>
               <div class="col-sm-4">
                   <input name="dept" class="form-control" th:value="${deptName}" type="text"  readonly="readonly">
               </div>
           </div>
        </form>
        <div class="row">
	        <div class="col-sm-offset-5 col-sm-10">
	            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
	            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
	        </div>
	    </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
    	var icon = "<i class='fa fa-times-circle'></i> ";
        var prefix = ctx + "yy/project"
        $("#form-project-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.saveTab(prefix + "/add", $('#form-project-add').serialize());
            }
        }
        
        $("input[name='lxAt']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        
      	//选择用户selectCustomer
		function selectCustomer() {
			var options = {
		       title: '合作联系人',
		       url: "/yy/customer/invokeCustomer",
		       width: '1000',
		       height: '670',
		       callBack: doSubmitCustomer
		    };
		    $.modal.openOptions(options);
		}
	 	
		function doSubmitCustomer(index, layero){
            var rows = layero.find("iframe")[0].contentWindow.getSelections();
            if (rows.length == 0) {
                $.modal.alertWarning("请选择一条记录！");
                return;
            }
            
            if (rows.length > 1) {
                $.modal.alertWarning("请勿选择多条记录！");
                return;
            }
            
            $("#customerId").val(rows[0].id);
            $("#customerName").val(rows[0].ckdw);
            $("#customerStr").val(rows[0].ckdw);
            $.modal.closeAll();
        }
		
		//选择用户level1
		function selectlevel1() {
			var options = {
		       title: '选择用户',
		       url: "/sj/config/invokeUser",
		       width: '1000',
		       height: '670',
		       callBack: doSubmitSwyy
		    };
		    $.modal.openOptions(options);
		}
	 	
		function doSubmitSwyy(index, layero){
            var rows = layero.find("iframe")[0].contentWindow.getSelections();
            if (rows.length == 0) {
                $.modal.alertWarning("请选择一条记录！");
                return;
            }
            
            if (rows.length > 1) {
                $.modal.alertWarning("请勿选择多条记录！");
                return;
            }
            
            $("#swyyId").val(rows[0].userId);
            $("#swyy").val(rows[0].userName);
            $("#swyyStr").val(rows[0].userName);
            $.modal.closeAll();
        }
		
		//选择用户level1
		function selectlevel2() {
			var options = {
		       title: '选择用户',
		       url: "/sj/config/invokeUser",
		       width: '1000',
		       height: '670',
		       callBack: doSubmitBmspr
		    };
		    $.modal.openOptions(options);
		}
	 	
		function doSubmitBmspr(index, layero){
            var rows = layero.find("iframe")[0].contentWindow.getSelections();
            if (rows.length == 0) {
                $.modal.alertWarning("请选择一条记录！");
                return;
            }
            
            if (rows.length > 1) {
                $.modal.alertWarning("请勿选择多条记录！");
                return;
            }
            
            $("#bmsprId").val(rows[0].userId);
            $("#bmspr").val(rows[0].userName);
            $("#bmsprStr").val(rows[0].userName);
            $.modal.closeAll();
        }
    </script>
</body>
</html>